package a66weding.com.jiehuntong.dao.db.headportrait;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

import a66weding.com.jiehuntong.dao.db.TastBean;

/**
 * Created by admin on 2016/8/23.
 */
public class HeadDao {
    private HeadBeanOpenHelper headBeanOpenHelper;
    public HeadDao(Context context){
        headBeanOpenHelper = new HeadBeanOpenHelper(context);
    }

    /**
     * 添加数据;
     * @param name
     * @param phone
     * @return
     */
    public long add(String name, String phone) {
        SQLiteDatabase db =  headBeanOpenHelper.getWritableDatabase();
        // 其实就是一个map集合
        ContentValues values = new ContentValues();
        values.put("task", name);
        values.put("Pictrue", phone);
        long result = db.insert(HeadBean.MemeryId, null, values);
        db.close();
        return result;
    }

    /**
     * 查找全部;返回list集合;;
     */

    /**
     * 查找全部
     * @return
     */
    public List<TastBean> findAll() {
        SQLiteDatabase db =headBeanOpenHelper.getReadableDatabase();
        List<HeadBean> list = new ArrayList<HeadBean>();
        Cursor cursor = db.query("person",
                new String[] {  "task", "Pictrue" }, null, null, null, null, null);
        while (cursor.moveToNext()) {
            String name = cursor.getString(0);
            String flag = cursor.getString(1);
            HeadBean bean = new HeadBean();
            bean.setPictrue(name);
            list.add(bean);
        }
        cursor.close();
        db.close();
        return null;
    }

}
